package com.ysd.Servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.websocket.Session;

import com.ysd.dao.impl.ChanPinXiangQingNeiRongDaoimpl;
import com.ysd.dao.impl.ChanPingShouSuoDaoimpl;
import com.ysd.dao.impl.FeiLeiBiaoIdDaoImpl;
import com.ysd.dao.impl.FenLeiBiaoDaoimpl;
import com.ysd.entity.ChanPinXiangQing;
import com.ysd.entity.FenLeiBiao;


public class ChanPingShouSuoServlet extends HttpServlet {
	
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");//设置文字的文本类型
		HttpSession session=request.getSession();//创建session对象
		
		FenLeiBiaoDaoimpl flbd=new FenLeiBiaoDaoimpl();// 获得产品分类表的实现类
		ArrayList<FenLeiBiao> flb=flbd.getFenLeiBiao();// 获得产品分类表的数据
		request.setAttribute("flb", flb);//吧产品分类表的数据存到下个页面
		
		
		
		ChanPingShouSuoDaoimpl cpssDao=new ChanPingShouSuoDaoimpl();//获得通过chanPinName模糊查询产品的实现类
		String xiyangyang=request.getParameter("sousuo");//接守前台form表单name值为sousuo文本框的值用喜洋洋来接收
		ArrayList<ChanPinXiangQing> cpxqss= cpssDao.getChanPingShouSuo(xiyangyang);// 获得通过chanPinName模糊查询产品详情的数据
		request.setAttribute("cpxqss", cpxqss);//把 通过chanPinName模糊查询产品详情的数据存到下个页面
		session.setAttribute("cpxqss", cpxqss);//把 通过chanPinName模糊查询产品详情的数据存到session中
		request.setAttribute("xiyangyang", xiyangyang);
		
		
		request.getRequestDispatcher("chanpingshousuo.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
